package com.lanchetech.merchant.controller;

import com.lanchetech.bean.request.PageReq;
import com.lanchetech.bean.request.SpuReq;
import com.lanchetech.bean.response.BasePageResp;
import com.lanchetech.bean.response.BaseResp;
import com.lanchetech.bean.response.ResultData;
import com.lanchetech.bean.response.SpuResp;
import com.lanchetech.entity.MsgUser;
import com.lanchetech.entity.Tenant;
import com.lanchetech.merchant.aop.OperatorLog;
import com.lanchetech.merchant.service.ServiceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@Api(value = "客服接口", tags = "客服接口")
@RequestMapping("/api/service")
@RestController
public class ServiceController {

    @Autowired
    ServiceService serviceService;

    @OperatorLog("编辑客服")
    @ApiOperation("编辑客服")
    @PreAuthorize("hasAuthority('service.index.edit.auth')")
    @PostMapping("/editMsgUser")
    public BaseResp editMsgUser(@RequestBody MsgUser msgUser) {
        return serviceService.editMsgUser(msgUser);
    }

    @ApiOperation("获取客服分页")
    @PreAuthorize("hasAuthority('service.index')")
    @PostMapping("/getMsgUserPage")
    public ResultData<BasePageResp<MsgUser>> getMsgUserPage(@RequestBody PageReq req) {
        return serviceService.getMsgUserPage(req);
    }

    @ApiOperation("获取客服详情")
    @GetMapping("/getMsgUserDetail")
    public ResultData<MsgUser> getMsgUserDetail(@RequestParam("id") Long id) {
        return serviceService.getMsgUserDetail(id);
    }

    @OperatorLog("删除客服")
    @PreAuthorize("hasAuthority('service.index.delete.auth')")
    @ApiOperation("删除客服")
    @GetMapping("/deleteMsgUser")
    public BaseResp deleteMsgUser(@RequestParam("id") Long id) {
        return serviceService.deleteMsgUser(id);
    }


    @ApiOperation("获取平台客服")
    @GetMapping("/getPlatformMsgUser")
    public ResultData<MsgUser> getPlatformMsgUser(@RequestParam("msgUserId") Long msgUserId) {
        return serviceService.getPlatformMsgUser(msgUserId);
    }
}
